package com.hmall.item.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hmall.item.mapper.ItemMapper;
import com.hmall.item.pojo.Item;
import com.search.common.dto.PageDTO;
import com.hmall.item.service.IItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ItemService extends ServiceImpl<ItemMapper, Item> implements IItemService {
    @Autowired
    ItemMapper itemMapper;

    /**
     * 分页查询
     * @param page
     * @param size
     * @return
     */
    @Override
    public PageDTO pageGet(long page, long size) {
        Page<Item> items =  new Page<>(page, size);
        itemMapper.selectPage(items,null);
        return new PageDTO<Item>(items.getTotal(),items.getRecords());
    }

    @Override
    public List<Item> getAll() {
        return itemMapper.getAll();
    }
}
